#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
    bool isValidSudoku(vector<vector<char>>& board) {
        vector<vector<bool>>rowused(9, vector<bool>(9, false));
        vector<vector<bool>>colused(9, vector<bool>(9, false));
        vector<vector<bool>>boxused(9, vector<bool>(9, false));
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                if (board[i][j] != '.') {
                    int num = board[i][j] - '1';
                    int box = (i / 3) * 3 + j / 3;
                    if (rowused[i][num] || colused[j][num] || boxused[box][num]) {
                        return false;
                    }
                    rowused[i][num] = true;
                    colused[j][num] = true;
                    boxused[box][num] = true;
                }
            }
        }
        return true;
    }
};